package top.kaoshanji.r1ch04a;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/4 19:28
 */
public class ApplicationContextTest {

    /**
     * 代码清单test-r1ch04a-97页a：从ApplicationContext中获取Bean对象
     */
    @Test
    public void getBean() {

        // 通过一个带 @Configuration 注解的 POJO 装载 Bean 配置
        ApplicationContext context = new AnnotationConfigApplicationContext(CarConfig.class);

        Car car = context.getBean("car", Car.class);
        Assert.assertNotNull(car);

    }

}
